package com.ruoyi.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.service.SysExcelservice;
import com.ruoyi.system.service.SysOrderService;
import com.ruoyi.system.vo.req.AnalyExcelReqVO;
import com.ruoyi.system.vo.req.order.*;
import com.ruoyi.system.vo.resp.AnalysisRespVO;
import com.ruoyi.system.vo.resp.SysOrderRespVo;
import com.ruoyi.system.vo.resp.SysOrderSpeedRespVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.text.ParseException;
import java.util.HashMap;
import java.util.List;

/**
 * @author xdh
 * @title SysExcelController
 * @date 2024/7/1 14:03
 * @description TODO
 */
@RestController
@RequestMapping("/order")
@Api(tags = "订单管理相关接口")
public class SysOrderController {


    @Autowired
    private SysOrderService sysOrderService;


    @ApiOperation("订单分页列表")
    @PostMapping("/page")
    public R<IPage<SysOrderRespVo>> page(@RequestBody OrderSelectRequestVO req) {
        return R.ok(sysOrderService.listPage(req));
    }




    @ApiOperation("协同订单列表")
    @GetMapping("/syner/list")
    public R<List<SysOrderRespVo>> synerList(Integer orderId) {
        return R.ok(sysOrderService.synerList(orderId));
    }


    @ApiOperation("核查反馈新增")
    @PostMapping("/insert")
    public R<HashMap<String,Integer>> insert(@RequestBody OrderStrikeRequestVO req) {
        return R.ok(sysOrderService.insert(req));
    }


    @ApiOperation("核查反馈详情")
    @GetMapping("/detail/{orderId}")
    public R<OrderStrikeResponseVO> detail(@PathVariable Integer orderId) {
        return R.ok(sysOrderService.detail(orderId));
    }

    @ApiOperation("获取当前用户组织的下级单位")
    @GetMapping("/dept/list")
    public R<List<OrderDeptResponseVO>> deptList() {
        return R.ok(sysOrderService.deptListById());
    }


    @ApiOperation("任务分发")
    @PostMapping("/dispense")
    public R<Boolean> dispense(@RequestBody OrderDispenseRequestVO req) {
        return R.ok(sysOrderService.dispense(req));
    }


    @ApiOperation("订单数据")
    @GetMapping("/data")
    public R<OrderResponseVO> data(){
        return R.ok(sysOrderService.data());
    }


    @ApiOperation("订单最近12个月数据")
    @GetMapping("/data12")
    public R<List<OrderDataResponseVO>> data12() throws ParseException {
        return R.ok(sysOrderService.data12());
    }


    @ApiOperation("进度")
    @GetMapping("/speed/{orderId}")
    public R<SysOrderSpeedRespVO> speed(@PathVariable Integer orderId){
        return R.ok(sysOrderService.speed(orderId));
    }








}
